package com.bier.fishproject.activity;

import com.bier.fishproject.R;
import com.mining.app.zxing.view.ProgressDialogUtils;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.PopupWindow;
import android.widget.Toast;
/**
 * 公共activity类
 * @author Administrator
 *
 */
@SuppressLint("NewApi") public class BaseActivity extends FragmentActivity{
	protected PopupWindow mPopuwindow=null;
	protected void onCreate(Bundle arg0) {
		getWindow().setBackgroundDrawable(null); 
		super.onCreate(arg0);
	}
	
	/**
	 * @功能描述：显示String类型的Toast
	 * @@param text
	 */
	protected void showShortToast(String text) {
        Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
    }
	
	
	/**
	 * @功能描述：含有Bundle通过Class跳转界面
	 * @@param cls：要跳转的class界面
	 * @@param bundle：传输的数据封装 参数
	 */
	 protected void startActivity(Class<?> cls, Bundle bundle) {
	        Intent intent = new Intent();
	        intent.setClass(getApplicationContext(), cls);
	        if (bundle != null) {
	            intent.putExtras(bundle);
	        }
	        startActivity(intent);
	    }
	 
	 
	  /**
		 * @功能描述：可以返回的跳转
		 * @@param cls：要跳转的class界面
		 * @@param bundle：传输的数据封装
		 * @@param index：   
		 */
	 protected void startForResultActivity(Class<?> cls, Bundle bundle,int index) {
	        Intent intent = new Intent();
	        intent.setClass(getApplicationContext(), cls);
	        if (bundle != null) {
	            intent.putExtras(bundle);
	        }
	        startActivityForResult(intent,index);
	  }
	 
	 
	//弹出加载圈
    protected void loadView(String text){
    	ProgressDialogUtils.getInstance().startProgressDialog(BaseActivity.this,text);
	 }
	    
    //关闭加载圈
	 protected void endView(){
	    ProgressDialogUtils.getInstance().stopProgressDialog(BaseActivity.this);
	 }
	 
	 
	 /**
	     * 
	     * @功能描述：从底部弹出
	     * @@param parent
	     * @@param x
	     * @@param y
	     * @@param view
	     * @@param parameter
	     */
	    protected void bottomPopupWindow(int x, int y,View view) {
			mPopuwindow = new PopupWindow(view,ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
			ColorDrawable cd = new ColorDrawable(-0000);
			mPopuwindow.setBackgroundDrawable(cd);
			mPopuwindow.setOutsideTouchable(false);
			mPopuwindow.setFocusable(true);
			mPopuwindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);  
			mPopuwindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 
			mPopuwindow.setAnimationStyle(R.style.animation);
			mPopuwindow.showAtLocation(getWindow().getDecorView(), Gravity.BOTTOM, x, y);
		}
}
